package com.yunlong.softpark.service.impl;

import com.yunlong.softpark.mapper.RecordMapper;
import com.yunlong.softpark.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: Cui
 * @Date: 2020/8/23
 * @Description:
 */
@Service
public class RecordServiceImpl implements RecordService {

    @Autowired
    RecordMapper recordMapper;

    @Override
    public void saveRecord(String remoteAddr, int behavior,  String behaviorId ,String userId) {

        String recordId = UUID.randomUUID().toString().replace("-","");
        switch (behavior){
            case 1:{
                //登录记录ip
                recordMapper.insertRecord(recordId,remoteAddr,behavior,null,userId,new Date());
                break;
            }
            case 2:
            case 3: {
                //下载记录ip
                recordMapper.insertRecord(recordId,remoteAddr,behavior,behaviorId,userId,new Date());
                break;
            }//评论记录ip
            case 4:{
                //反馈记录ip
                recordMapper.insertRecord(recordId,remoteAddr,behavior,behaviorId,userId,new Date());
            }
            case 5:{
                //对网站的反馈
                recordMapper.insertRecord(recordId,remoteAddr,behavior,behaviorId,null,new Date());
            }
            case 6:{
                //上传栏目的记录
                recordMapper.insertRecord(recordId,remoteAddr,behavior,behaviorId,userId,new Date());
            }
            case 7:{
                //上传软件的记录
                recordMapper.insertRecord(recordId,remoteAddr,behavior,behaviorId,userId,new Date());
            }
        }

    }
}
